package com.ly.demo.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Base64;


/**
 * @author shenzhuojun
 * @version 1.0 2023/10/10 7:50 下午
 * @Description
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class VoiceToTextReqReq {

    private String voiceBase64;

    public void getAudioDurationInSeconds() {

        byte[] audioBytes = Base64.getDecoder().decode(voiceBase64);

        String filePath = "output.mp3"; // 保存的 WAV 文件路径
        try (FileOutputStream fos = new FileOutputStream(filePath)) {
            fos.write(audioBytes);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}

